package Testing;

import DAO.CounterDAO;
import DAO.Memcached;
import DAO.StatusDAO;
import DAO.TagDAO;
import DAO.UserDAO;
import POJO.*;
import SearchSolr.solrSearch;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cassandra.thrift.Cassandra;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

public class apptien {

    public static void main(String[] args) throws Exception {
        try {
            TTransport tr = new TFramedTransport(new TSocket(Common.Constants.HOST, Common.Constants.PORT));
            TProtocol proto = new TBinaryProtocol(tr);
            Cassandra.Client client = new Cassandra.Client(proto);
            tr.open();

            client.set_keyspace(Common.Constants.KEYSPACE);
            Memcached.run();
            
            TagDAO tag = TagDAO.getInstance(client);
            StatusDAO status = StatusDAO.getInstance(client);
            UserDAO user = UserDAO.getInstance(client);
//            TagPOJO tagP = tag.selectTagWithTagName("Chúc Tết");
//            System.out.println(tagP);
            
//            List<TagPOJO> listTag = tag.selectAllTag();
//            System.out.println(listTag);
            
//            List<TagNameAndCounter> listTagNameAndCounter = tag.selectAllTagNameAndCounter();
//            System.out.println(listTagNameAndCounter);
            
//            tag.cachedAllTagNameAndCounter();

           
//            List<TagNameAndCounter> listTagNameAndCounter = tag.selectTagNameAndCounter(3);
//            System.out.println(listTagNameAndCounter);
            
//            boolean result = tag.removeStatusInATag("Chúc Tết", "1133");
//            System.out.println(result);
            
//            boolean result = tag.updateIsPublicOnATag("Chúc Tết", false);
//            System.out.println(result);
              
            
//            tag.insertTagInfo("testTag", true);
//            List<String> listStatusID = new ArrayList<String>();
//            listStatusID.add("2000");
//            listStatusID.add("2001");
//            tag.insertListStatusInToTag("testTag", listStatusID);
            
//            StatusDAO status = StatusDAO.getInstance(client);
//            status.updateTagsOnAStatus("100", "thành công,testTag");
            
//            tag.deleteTag("0");
            
            
//            List<String> listStatusID = status.selectStatusIDFromTag("hài hước");
//            System.out.println(listStatusID);
            
            
//            CounterPOJO counterPOJO = CounterDAO.getCounter(client);
//            System.out.println(counterPOJO);
            
//            UserDAO user = UserDAO.getInstance(client);
//            UserPOJO userPOJO = user.selectAllInfoOfAUser("481082310");
//            System.out.println(userPOJO);
            

//            List<String> listStatusID = status.getListPagingOnATag("hài hước", 5);
//            System.out.println(listStatusID);            
            
//            List<StatusPOJO> listStatus = status.searchStatusByContent("1 thuong", "0", "100", "2");
//            List<UserPOJO> listUser = user.selectListAdminUser();
//            System.out.println(listUser);
            
//            solrSearch solr = new solrSearch();
//            solr.deleteStatus("39601218984020");
            
            List<StatusPOJO> listStatus = status.selectTopStatus(5);
            System.out.println(listStatus);
            Memcached.stop();                    
            tr.close();
        } catch (TException ex) {
            Logger.getLogger(apptien.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
